package com.art.common.utils;

/**
 * HTTP结果封装
 * @author Louis
 * @date Oct 29, 2018
 */
public class HttpResult {

	private int code = 200;
	private String msg;
	private Object data;

	/**
	 * 未登录异常码
	 */
	public final static int NOT_LOGIN_CODE=110;
	public final static String NOT_LOGIN_DESC="登陆过期，请重新登陆";

	public static HttpResult error() {
		return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
	}
	
	public static HttpResult error(String msg) {
		return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
	}
	
	public static HttpResult error(int code, String msg) {
		HttpResult r = new HttpResult();
		r.setCode(code);
		r.setMsg(msg);
		return r;
	}

	public static HttpResult ok(String msg) {
		HttpResult r = new HttpResult();
		r.setMsg(msg);
		return r;
	}
	
	public static HttpResult ok(Object data) {
		HttpResult r = new HttpResult();
		r.setData(data);
		return r;
	}

	public static HttpResult ok(String msg, Object data) {
		HttpResult r = new HttpResult();
		r.setMsg(msg);
		r.setData(data);
		return r;
	}
	public static HttpResult ok(Integer code, String msg, Object data){
		HttpResult r = new HttpResult();
		r.setCode(code);
		r.setMsg(msg);
		r.setData(data);
		return r;
	}
	public static HttpResult ok() {
		return new HttpResult();
	}

	public static HttpResult ok(int code, String msg){
	    HttpResult r = new HttpResult();
	    r.setCode(code);
	    r.setMsg(msg);
	    return r;
    }

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
}
